//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "patcher.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TmainForm *mainForm;

AnsiString getAddOption(int);
int checkFile();
int patchFile(AnsiString, int);

//---------------------------------------------------------------------------
__fastcall TmainForm::TmainForm(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TmainForm::patchButtonClick(TObject *Sender)
{
	int langOption, patchOption;
	AnsiString addOption;
	bool succes;

	patchOption = checkFile();

	if (patchOption == -1) {
		ShowMessage("File was not found");
	} else {
		langOption = this -> langComboBox -> ItemIndex;

		if (langOption == -1) {
			ShowMessage("Choose a language");
		} else {
			succes = patchFile(addOption, patchOption);

			if (succes == true) {
				ShowMessage("Patch complete");
				exit(1);
			} else {
				ShowMessage("Patch failed");
			}
		}
	}
}
//---------------------------------------------------------------------------
AnsiString getAddOption(int opt)
{
	AnsiString addOpt1 = "AddVMOption -Duser.language=",
			   addOpt2 = "AddVMOption -Duser.country=",
			   langOpt,
			   counOpt,
			   addOpt;

	switch (opt) {
		case 0: langOpt = "ch"; counOpt = "ch"; break; // Chinese
		case 1: langOpt = "nl"; counOpt = "nl"; break; // Dutch
		case 2: langOpt = "de"; counOpt = "de"; break; // German
		case 3: langOpt = "en"; counOpt = "us"; break; // English (UK)
		case 4: langOpt = "en"; counOpt = "uk"; break; // English (US)
		case 5: langopt = "th"; coutOpt = "th"; break; // Thai
		case 6: langopt = "fr"; coutOpt = "fr"; break; // French
		case 6: langopt = "sp"; coutOpt = "ve"; break; // Spanish
		default:
		;
	}

	addOpt = addOpt1 + langOpt + " " + addOpt2 + counOpt;
	return addOpt;
}
//---------------------------------------------------------------------------
int checkFile()
{
	// check the file.
	return 0;
}
//---------------------------------------------------------------------------
int patchFile(AnsiString addOpt, int PatchOpt)
{
	// Patch the file.
	return 0;
}
//---------------------------------------------------------------------------
